
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <table id="app">
     <tr> 
         <td><product v-for="obj in products" :pro="obj"></product></td>
        <!-- <product v-for="obj in products" :pro="obj"></product> -->
     </tr>

    </table>
</body>

<!---用局部组件展示商品---->

<script>

   //局部组件
    let product={
        props:['pro'],
        template:"<td>{{pro.name}}-----{{pro.price}}</td>"
    }

  //普通的vm实例data可以是对象也可以方法
  new Vue({
      el:"#app",
      data:{
         products:[
             {name:'茅台',price:1499,img:'自己找'}
         ]
      },
      components:{
        product:product,//可以简写为 product
      }
  })
</script>
</html>